package logic

import (
	"context"
	"demo/internal/svc"
	"demo/internal/types"

	"demo/model"

	"github.com/zeromicro/go-zero/core/logx"
)


type ServeyClasifyInfoLogic struct{
	logx.Logger
	ctx context.Context
	svcCtx *svc.ServiceContext
	model model.ServeyClassifyModel
}

func NewServeyClassifyInfoLogic(ctx context.Context,svcCtx *svc.ServiceContext)*ServeyClasifyInfoLogic{
	return &ServeyClasifyInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx: ctx,
		svcCtx: svcCtx,
		model: model.NewServeyClassifyModel(svcCtx.Orm,svcCtx.GormDB),
	}
}

func (l *ServeyClasifyInfoLogic)Info(req *types.ServeyClassifyInfoRequest)(resp *types.ServeyClassifyInfoResponse,err error){
	

	data,err := l.model.FindPageListByPage(l.ctx,req.Id,req.CreatorId,req.Page,req.PageSize,req.ClfName,l.model.ListBuilder(),false,"clf_name")
		
	if err != nil{
		return nil,err
	}

	v := make([]types.ServeyClassifyInfoItemResponse,0)
	for _,re := range data{
		v = append(v, types.ServeyClassifyInfoItemResponse{
			Id: re.Id,
			ClfName: re.ClfName,
			ClfDesc: re.ClfDesc.String,
			CreatorId: re.CreatorId,
			ServeyNum: re.ServeyNum,
		})
	}
	return &types.ServeyClassifyInfoResponse{
		Code: 200,
		Msg: "查询成功",
		Data: v,
	},nil
}